﻿using DFGK_WMS.Model.DTO;
using DFGK_WMS.Model.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DFGK_WMS.IRepository
{
    /// <summary>
    /// 出库表管理
    /// </summary>
    public interface ITShippingOrderDetailRepository : IBaseRepository<TShippingOrderDetail>
    {
        #region 添加出库单弃用
        /*
        /// <summary>
        /// 添加出库管理
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        bool AddTShippingOrderDetail(TShippingOrderDetail model);
       

        /// <summary>
        /// 添加出库管理 多个物料版本
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        bool AddTShippingOrderDetailPlus(TShippingOrderDetailPlusDTO model, out string msg);
                */
        #endregion

        #region 修改出库单弃用
        ///// <summary>
        ///// 修改出库管理（弃用）
        ///// </summary>
        ///// <param name="model"></param>
        ///// <returns></returns>
        //bool UpdateTShippingOrderDetail(TShippingOrderDetail model);
        #endregion

        #region 一件选定弃用
        ///// <summary>
        ///// 一键选定（弃用）
        ///// </summary>
        ///// <param name="materid">物料Id</param>
        ///// <param name="count">出库数量</param>
        ///// <param name="whid">库房Id</param>
        ///// <param name="areaid">库区Id</param>
        ///// <param name="supid">供应商Id</param>
        ///// <param name="owid">货主Id</param>
        ///// <returns></returns>
        //List<TInventory> GetAllTShippingLockCell(int materid, int count, int whid, int areaid, int supid, int owid);
        ///// <summary>
        ///// 一键选定(弃用)
        ///// </summary>
        ///// <returns></returns>
        //List<TShippingLockCell> GetAllTShippingLockCell(TShippingOrderDetail model);
        ///// <summary>
        ///// 一键选定(弃用)
        ///// </summary>
        ///// <param name="model"></param>
        ///// <returns></returns>
        //bool SelectTShippingOrderDetail(TShippingOrderDetail model);
        #endregion

        /// <summary>
        /// 往sqlite中写入数据
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        bool AddSqliteDetail(GroupShippingOrderDto m,int id, out string message);


        /// <summary>
        /// 在sqlite中获取数据
        /// </summary>
        /// <returns></returns>
        List<GroupShippingOrderDto> GetShippingOrderDtos();

        /// <summary>
        /// 通过出库单号获取数据
        /// </summary>
        /// <param name="OrderSn"></param>
        /// <returns></returns>
        GroupShippingOrderDto GetGroupShippingOrderDtoByOrdersn(string OrderSn);

        /// <summary>
        /// 入库后减去库存
        /// </summary>
        /// <returns></returns>
        bool submitShipping(out string message);

        /// <summary>
        /// 封装方法
        /// </summary>
        /// <param name="inventories"></param>
        /// <returns></returns>
        bool IsInventoryWarn(List<TInventory> inventories);

        /// <summary>
        /// 带出所有器材
        /// </summary>
        /// <returns></returns>
        List<TInventory> GetMaterialAll(out int totalCount,string? mname,int ? materialCategoryId,int pageIndex, int pageSize);

        /// <summary>
        /// 根据器材ID带出器材其他信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        TMaterialSelDto GetMaterialById(int id);

        /// <summary>
        /// 添加出库单
        /// </summary>
        /// <param name="m"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        bool AddTShippingOrderDetail(GroupShippingOrderDto m,out string message);

        /// <summary>
        /// 删除出库管理
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        bool DeleteTShippingOrderDetail(string OrderSn);

        /// <summary>
        /// 删除出库管理  多个物料版本
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        bool DeleteTShippingOrderDetailPlus(TShippingOrderDetailPlusDTO model);

        /// <summary>
        /// 修改出库管理
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        bool UpdateTShippingOrderDetail(GroupShippingOrderDto m);

        /// <summary>
        /// 修改出库管理  多个物料版本
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        bool UpdateTshippingOrderDetailPlus(TShippingOrderDetailPlusDTO models);

        /// <summary>
        /// 根据Id查看
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        TShippingOrderDetail GetByIdTShippingOrderDetail(string OrderSn);

        /// <summary>
        /// 根据单号查询
        /// </summary>
        /// <param name="OrderSn"></param>
        /// <returns></returns>
        List<TShippingOrderDetail> GetByOrderSnTShipping(string OrderSn);

        /// <summary>
        /// 显示出库单
        /// </summary>
        /// <param name="status"></param>
        /// <param name="warehouseid"></param>
        /// <param name="name"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalCount"></param>
        /// <returns></returns>
        List<TShippingOrderDetail> GetAllTShippingOrderDetail(string? StartTime, string? EndTime, int? billType, int? status, int? warehouseid,string rolecode, int pageIndex,int pageSize, out int totalCount);

        /// <summary>
        /// 显示出库单 多个物料版本
        /// </summary>
        /// <param name="status"></param>
        /// <param name="warehouseid"></param>
        /// <param name="name"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalCount"></param>
        /// <returns></returns>
        List<GetChukuDanDTO> GetAllTShippingOrderDetailPlus(int? billType, int? houseid, string? name, int pageIndex, int pageSize, out int totalCount);

        /// <summary>
        /// 修改状态
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        bool UpdTShippingOrderDetailState(ReceivingOrderDetailDto model);

        /// <summary>
        /// 根据物料id返回批次号和数量
        /// </summary>
        /// <param name="mid"></param>
        /// <returns></returns>
        BatchNoMaxCount GetMaterialIdById(int mid, string batchNO = null, int? qualityState = null, string warehouseCode = "", string areaCode = "", int? ownerId = null, int? supplierId = null, string produceFactory = "");     
        /// <summary>
        /// 查看货品明细
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        List<TShippingGoodsDetail> GetOneTShippingGoodsDetail(int id, int pageIndex, int pageSize, out int totalCount);

        List<TShippingGoodsDetail> GetByNameShippingGoodsDetail(string? name, int pageIndex, int pageSize, out int totalCount);


        // List<TShippingOrderDetail> GetTest();
        ///获取出库详情
        List<TShippingOrderDetail> GetTShippingOrder(int pageIndex, int pageSize, out int totalCount);

        /// <summary>
        /// 关联单号
        /// </summary>
        /// <param name="OrderSn"></param>
        /// <returns></returns>
        List<TShippingLockCell> GetShippingLockCells(string OrderSn,out string message);

        List<ShippingPositionDto> GetPositionByMaterial(string MaterialCode);

        List<string> GetAllCellCode(GroupShippingOrderDto model);

        /// <summary>
        /// 根据单位名称获取id
        /// </summary>
        /// <param name="unitName"></param>
        /// <returns></returns>
        int GetUnitIdByUnitName(string unitName);

        /// <summary>
        /// 根据装备编码查询装备id
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        int GetMaterialCategoryByCode(string code);

    }
}